// $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString
/*
 * ClientMain.java
 */
package edu.gatech.oad.networking;

import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.UnsupportedLookAndFeelException;

import org.jhotdraw.app.osx.OSXAdapter;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ClientMain {
	
	public static void main(String[] args) {
		if (System.getSecurityManager() == null) {
			System.setSecurityManager(new SecurityManager());
		}
		
		//Set the look and feel to Nimbus
		try {
		    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
		        if ("Nimbus".equals(info.getName())) {
		            UIManager.setLookAndFeel(info.getClassName());
		            break;
		        }
		    }
		} catch (UnsupportedLookAndFeelException e) {
		    // handle exception
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
		    // handle exception
			e.printStackTrace();
		} catch (InstantiationException e) {
		    // handle exception
			e.printStackTrace();
		} catch (IllegalAccessException e) {
		    // handle exception
			e.printStackTrace();
		}
		
		OSXAdapter.setQuitHandler(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				System.out.println("About to quit...");
				ClientManager.sharedManager().disconnectFromServer();
				System.exit(0);
			}
			
		});
		
		ClientManager.sharedManager().beginDiscovery();
	}
	
}
